package com.xxk.wdis.mapper;

import com.xxk.wdis.entity.DrugInputOutput;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author cwb
 * @since 2020-04-02
 */
@Component
@Mapper
public interface DrugInputOutputMapper extends BaseMapper<DrugInputOutput> {
    /**
     * 单个药品库存检测
     *
     * @param drugId 药品id
     * @return Map<String, Object>
     */
    @Select("SELECT drug_id, drug_name,sum(number) FROM drug_input_output WHERE drug_id = #{drugId} GROUP BY  drug_id, drug_name")
    Map<String, Object> kucunCheck(@Param("drugId") Long drugId);

    /**
     * 按流水号查询
     *
     * @return
     */
    @Select("SELECT DISTINCT(serial_no) ,type,`status`,operator,gmt_create,auditing_time,auditor FROM drug_input_output")
    List<Map<String, Object>> ListByserial_no();
}
